package cn.xshi.sys.service.impl;

import cn.xshi.common.base.BaseService;
import cn.xshi.common.util.ExceptionUtil;
import cn.xshi.sys.dao.SysKWordsDao;
import cn.xshi.sys.model.SysKWords;
import cn.xshi.sys.service.SysKWordsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Desc 关键词（敏感词）
 * @Author 邓纯杰
 * @CreateTime 2012-12-12 12:12:12
 */
@Service
public class SysKWordsServiceImpl extends BaseService implements SysKWordsService {

	@Resource
	private SysKWordsDao sysKWordsDao;

	/**
	 * 分页
	 * @param condition
	 * @return
	 */
	public List<SysKWords> getSysKwordsListByCondition(Map<String,Object> condition){
		try{
			return sysKWordsDao.getSysKwordsListByCondition(condition);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
	}

	/**
	 * 查询对象
	 * @param id
	 * @return
	 */
	public SysKWords getSysKwordsById(String id){
		try{
			return sysKWordsDao.getSysKwordsById(id);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
	}

	/**
	 * 添加
	 * @param sysKWords
	 * @return
	 */
	public int addSysKwords(SysKWords sysKWords){
		int i = 0;
		try {
			sysKWords.setCreateId(getCurrentAccountId());
			sysKWords.setCreateTime(getDate());
			i = sysKWordsDao.addSysKwords(sysKWords);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	 * 修改
	 * @param sysKWords
	 * @return
	 */
	public int updateSysKwords(SysKWords sysKWords){
		int i = 0;
		try {
			sysKWords.setUpdateId(getCurrentAccountId());
			sysKWords.setUpdateTime(getDate());
			i = sysKWordsDao.updateSysKwords(sysKWords);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	 * 删除
	 * @param condition
	 * @return
	 */
	public int delSysKwords(Map<String,Object> condition){
		int i = 0;
		try {
			i = sysKWordsDao.delSysKwords(condition);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}
}